/* Usage Meter for Claude: overlay inside the chat box */
.cuw-relative { position: relative !important; }

/* The water and the weather sit BEHIND whatever you type: the box becomes its own
   stacking context, so a layer at z-index -1 is drawn above the box's own background
   but below its text, caret, buttons and icons. */
.cuw-host { isolation: isolate; }
/* Inner wrappers with a solid colour would hide the water, so they go clear while it is on */
.cuw-clear { background: transparent !important; background-color: transparent !important; }

.cuw-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
  /* Blend so text stays crisp: multiply keeps dark text dark on light boxes,
     screen keeps light text light on dark boxes. */
  mix-blend-mode: multiply;
  opacity: .85;
  transition: opacity .4s ease;
  contain: strict;
}
.cuw-overlay[data-theme="dark"] { mix-blend-mode: screen; opacity: .72; }
.cuw-overlay[data-theme="dark"][data-intensity="subtle"] { opacity: .42; }
.cuw-overlay[data-theme="dark"][data-intensity="bold"] { opacity: .95; }
.cuw-overlay[data-intensity="subtle"] { opacity: .5; }
.cuw-overlay[data-intensity="bold"] { opacity: 1; }
.cuw-overlay[data-state="empty"] { opacity: 0 !important; }

/* Palette: light boxes (multiply) */
.cuw-overlay                            { --c1: #d9ecff; --c2: #c2e0ff; --c3: #9fcdff; }
.cuw-overlay[data-level="mid"]          { --c1: #ffefc9; --c2: #ffe1a0; --c3: #ffcd6e; }
.cuw-overlay[data-level="high"]         { --c1: #ffdcd8; --c2: #ffc2bb; --c3: #ff9e94; }
/* Palette: dark boxes (screen) */
.cuw-overlay[data-theme="dark"]                    { --c1: #154a86; --c2: #0f3a6c; --c3: #0a2a52; }
.cuw-overlay[data-theme="dark"][data-level="mid"]  { --c1: #7a5510; --c2: #60420b; --c3: #463006; }
.cuw-overlay[data-theme="dark"][data-level="high"] { --c1: #8a2a24; --c2: #6c1f1a; --c3: #4e1511; }

.cuw-water {
  --cuw-fill: 0;
  --cuw-speed: 8s;
  --cuw-amp: 1;
  position: absolute;
  inset: 0;
  transform: translateY(calc((1 - var(--cuw-fill)) * 100%));
  transition: transform 1.8s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}

.cuw-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--c2), var(--c3));
  transition: background .6s ease;
}

.cuw-wave {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: calc(100% + 240px);
  height: 14px;
  margin-bottom: -1px;
  transform-origin: 50% 100%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='14' viewBox='0 0 240 14'%3E%3Cpath d='M0 7 C30 0 90 0 120 7 S210 14 240 7 V14 H0 Z'/%3E%3C/svg%3E") repeat-x 0 100% / 240px 14px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='14' viewBox='0 0 240 14'%3E%3Cpath d='M0 7 C30 0 90 0 120 7 S210 14 240 7 V14 H0 Z'/%3E%3C/svg%3E") repeat-x 0 100% / 240px 14px;
}
.cuw-w1 { background: var(--c2); animation: cuw-drift var(--cuw-speed) linear infinite; }
.cuw-w2 {
  background: var(--c1);
  opacity: .8;
  height: 11px;
  -webkit-mask-size: 180px 11px; mask-size: 180px 11px;
  animation: cuw-drift-r calc(var(--cuw-speed) * 1.45) linear infinite;
}

@keyframes cuw-drift   { from { transform: translateX(0) scaleY(var(--cuw-amp)); } to { transform: translateX(-240px) scaleY(var(--cuw-amp)); } }
@keyframes cuw-drift-r { from { transform: translateX(-180px) scaleY(var(--cuw-amp)); } to { transform: translateX(0) scaleY(var(--cuw-amp)); } }

/* Pour effect when usage goes up */
.cuw-pour .cuw-wave { animation-duration: 1.6s; }
.cuw-pour .cuw-w1 { animation-name: cuw-drift, cuw-slosh; animation-duration: 1.6s, 2.4s; animation-iteration-count: infinite, 1; }
@keyframes cuw-slosh { 0% { height: 14px; } 25% { height: 24px; } 60% { height: 10px; } 100% { height: 14px; } }

.cuw-bubbles { position: absolute; inset: 0; }
.cuw-bubbles i {
  position: absolute;
  bottom: -10px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c1);
  opacity: 0;
}
.cuw-pour .cuw-bubbles i { animation: cuw-rise 2.4s ease-out forwards; }
.cuw-bubbles i:nth-child(1) { left: 12%; animation-delay: 0s; }
.cuw-bubbles i:nth-child(2) { left: 28%; animation-delay: .35s; width: 4px; height: 4px; }
.cuw-bubbles i:nth-child(3) { left: 46%; animation-delay: .15s; width: 8px; height: 8px; }
.cuw-bubbles i:nth-child(4) { left: 63%; animation-delay: .55s; }
.cuw-bubbles i:nth-child(5) { left: 79%; animation-delay: .25s; width: 5px; height: 5px; }
.cuw-bubbles i:nth-child(6) { left: 91%; animation-delay: .7s; width: 4px; height: 4px; }
@keyframes cuw-rise {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-120px); opacity: 0; }
}

/* Gentle idle bubbles when you are close to the limit */
.cuw-overlay[data-level="high"]:not(.cuw-pour) .cuw-bubbles i { animation: cuw-rise 4.5s ease-out infinite; }

/* Badge */
.cuw-badge {
  all: unset;
  position: absolute;
  top: -26px;
  right: 14px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font: 600 11px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  color: #0b3d74;
  background: #e3f0ff;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  transition: background .3s, color .3s;
}
.cuw-badge-i { display: inline-flex; font-size: 13px; line-height: 0; }
.cuw-badge-i svg { display: block; width: 1em; height: 1em; }
.cuw-badge-t { line-height: 1.4; }
.cuw-badge[hidden] { display: none; }
/* Last refresh failed: the numbers on screen are old */
.cuw-badge[data-stale="true"] { outline: 1px dashed currentColor; outline-offset: -1px; }
.cuw-badge.cuw-inside { top: 6px; right: 10px; }
.cuw-badge[data-level="mid"]  { color: #6b4500; background: #fff1cf; }
.cuw-badge[data-level="high"] { color: #8f1c14; background: #ffe1dd; }
.cuw-badge[data-level="none"] { color: #666; background: #eee; }
.cuw-badge[data-theme="dark"][data-level="none"] { color: #b5b3ab; background: #2d2d2b; }
.cuw-badge[data-theme="dark"]                    { color: #b9dbff; background: #17324f; }
.cuw-badge[data-theme="dark"][data-level="mid"]  { color: #ffd98a; background: #3d2d0c; }
.cuw-badge[data-theme="dark"][data-level="high"] { color: #ffb3aa; background: #451814; }
.cuw-badge:hover { filter: brightness(.97); }
.cuw-badge:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .cuw-wave, .cuw-bubbles i { animation: none !important; }
  .cuw-water { transition: none; }
}

/* ================= Scenes ================= */
/* Decoration layer: drawn normally (no blend) above the water */
.cuw-deco {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
  container-type: size;
  --cuw-fill: 0;
  --cuw-speed: 8s;
  --cuw-amp: 1;
  transition: opacity .4s ease;
}
.cuw-deco[data-state="empty"] { opacity: 0; }
/* While you are typing the scene calms down so the words stay easy to read */
.cuw-deco[data-typing="true"] { opacity: .3 !important; }
.cuw-overlay[data-typing="true"] .cuw-water { opacity: .72; }.cuw-deco[data-intensity="subtle"] { opacity: .6; }

/* ---------- Ship (Opus) ---------- */
.cuw-ship-track {
  position: absolute;
  left: 0; right: 0;
  /* Sits on the surface; kept inside the box near the top */
  bottom: calc(min(var(--cuw-fill), .74) * 100%);
  height: 0;
  transition: bottom 1.8s cubic-bezier(.2, .8, .2, 1);
  display: none;
}
.cuw-deco[data-scene="ship"] .cuw-ship-track { display: block; }
.cuw-ship-sail {
  position: absolute;
  bottom: -11px; /* hull sits a little under the waterline */
  left: 0;
  animation: cuw-sail 46s ease-in-out infinite;
}
.cuw-ship-bob {
  transform-origin: 50% 85%;
  animation: cuw-bob calc(var(--cuw-speed) * .45) ease-in-out infinite;
}
.cuw-ship { display: block; overflow: visible; filter: drop-shadow(0 1px 1px rgba(0,0,0,.18)); }
@keyframes cuw-sail {
  0%   { transform: translateX(8cqw) scaleX(1); }
  47%  { transform: translateX(calc(100cqw - 70px)) scaleX(1); }
  50%  { transform: translateX(calc(100cqw - 70px)) scaleX(-1); }
  97%  { transform: translateX(8cqw) scaleX(-1); }
  100% { transform: translateX(8cqw) scaleX(1); }
}
@keyframes cuw-bob {
  0%, 100% { transform: translateY(0) rotate(calc(-4deg * var(--cuw-amp))); }
  50%      { transform: translateY(calc(-2.5px * var(--cuw-amp))) rotate(calc(4deg * var(--cuw-amp))); }
}
/* Ship colors */
.cuw-ship .hull   { fill: #5b3a29; }
.cuw-ship .stripe { fill: #f3efe6; }
.cuw-ship .port   { fill: #f3efe6; }
.cuw-ship .mast   { fill: #4a3222; }
.cuw-ship .sail   { fill: #ffffff; stroke: #9aa7b6; stroke-width: .8; }
.cuw-ship .sail2  { fill: #f4f1ea; stroke: #9aa7b6; stroke-width: .8; }
.cuw-ship .flag   { fill: #d97757; }
.cuw-deco[data-theme="dark"] .cuw-ship .hull  { fill: #a0694a; }
.cuw-deco[data-theme="dark"] .cuw-ship .mast  { fill: #c49a7a; }
.cuw-deco[data-theme="dark"] .cuw-ship .sail  { fill: #ecebe4; stroke: none; }
.cuw-deco[data-theme="dark"] .cuw-ship .sail2 { fill: #d6d4cc; stroke: none; }
.cuw-deco[data-theme="dark"] .cuw-ship .stripe,
.cuw-deco[data-theme="dark"] .cuw-ship .port  { fill: #2b2a27; }
/* Storm mode near the limit: red flag, harder rocking */
.cuw-deco[data-level="high"] .cuw-ship .flag { fill: #e5484d; }

/* ---------- Snow (Sonnet) ---------- */
.cuw-snow { position: absolute; inset: 0; display: none; }
.cuw-deco[data-scene="snow"] .cuw-snow { display: block; }
.cuw-snow i {
  --flake: #8ea6c2;
  position: absolute;
  top: -14px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--flake);
  opacity: 0;
  font-style: normal;
  animation: cuw-fall var(--d) linear var(--delay) infinite;
}
/* Large flakes are drawn as a six-armed SVG mask instead of a text glyph */
.cuw-snow i.big {
  border-radius: 0;
  background: var(--flake);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 2v20M3.3 7l17.4 10M20.7 7L3.3 17'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 2v20M3.3 7l17.4 10M20.7 7L3.3 17'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cuw-snow i.off { display: none; }
.cuw-deco[data-theme="dark"] .cuw-snow i { --flake: #f2f5f9; }
@keyframes cuw-fall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: .95; }
  88%  { opacity: .9; }
  /* land on top of the snowdrift */
  100% { transform: translate(var(--dx), calc((1 - var(--cuw-fill)) * 100cqh + 8px)) rotate(220deg); opacity: 0; }
}

/* Snowdrift instead of water: soft, slow, icy */
.cuw-overlay[data-scene="snow"]                    { --c1: #f1f6fc; --c2: #dfe9f5; --c3: #c9d8ea; }
.cuw-overlay[data-scene="snow"][data-level="mid"]  { --c1: #f5f3ef; --c2: #e8e4dc; --c3: #d6d0c5; }
.cuw-overlay[data-scene="snow"][data-level="high"] { --c1: #f6efef; --c2: #ece0e0; --c3: #dccbcb; }
.cuw-overlay[data-scene="snow"][data-theme="dark"]                    { --c1: #5b6674; --c2: #46505c; --c3: #343c46; }
.cuw-overlay[data-scene="snow"][data-theme="dark"][data-level="mid"]  { --c1: #64666a; --c2: #4e5054; --c3: #393b3e; }
.cuw-overlay[data-scene="snow"][data-theme="dark"][data-level="high"] { --c1: #6a6264; --c2: #534c4e; --c3: #3d3739; }
.cuw-overlay[data-scene="snow"] .cuw-wave {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='14' viewBox='0 0 240 14'%3E%3Cpath d='M0 10 C25 3 55 3 80 8 S125 13 150 7 S205 2 240 10 V14 H0 Z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='14' viewBox='0 0 240 14'%3E%3Cpath d='M0 10 C25 3 55 3 80 8 S125 13 150 7 S205 2 240 10 V14 H0 Z'/%3E%3C/svg%3E");
  animation-duration: 90s !important;
}
.cuw-overlay[data-scene="snow"] .cuw-w1 { background: var(--c1); }
.cuw-overlay[data-scene="snow"] .cuw-w2 { display: none; }
.cuw-overlay[data-scene="snow"] .cuw-body { background: linear-gradient(to bottom, var(--c1), var(--c3)); }
.cuw-overlay[data-scene="snow"] .cuw-bubbles { display: none; }

@media (prefers-reduced-motion: reduce) {
  .cuw-ship-sail, .cuw-ship-bob { animation: none !important; }
  .cuw-ship-sail { transform: translateX(40cqw); }
  .cuw-snow i { animation: none !important; opacity: 0 !important; }
}
