/* ============================================================
   Beany reskin layer — sits on top of style.css.
   Applies brand polish (radius, shadows, glow, accent) to the
   existing workspace components without rewriting their layout.
   Loaded AFTER style.css so these rules take precedence.
   ============================================================ */

/* === Body polish === */
body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

/* === Buttons === */
button {
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 500;
  transition: background .12s ease, border-color .12s ease,
              transform .1s ease, box-shadow .12s ease, filter .12s ease;
}
button:hover { background: var(--bg-muted); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
  box-shadow: 0 6px 14px var(--accent-glow);
}
button.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button.big {
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
}

/* Cancel button — themed for both modes */
button.cancel {
  background: #ffe2e2;
  border-color: #f5b8b8;
  color: #b03030;
}
button.cancel:hover { background: #ffd0d0; }
html[data-theme="dark"] button.cancel {
  background: #4a2828;
  border-color: #6a3434;
  color: #ffd0d0;
}
html[data-theme="dark"] button.cancel:hover { background: #5a3030; }

/* === Theme toggle button === */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  padding: 0;
}
.theme-toggle:hover {
  color: var(--accent);
  background: var(--bg-muted);
  border-color: var(--accent-tint);
}
.theme-toggle svg { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }

/* === Topbar polish === */
.topbar {
  background: var(--surface);
  border-bottom-color: var(--border);
}
.brand {
  gap: 10px;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: var(--text-strong);
}

/* === App list page === */
.list-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.empty-state {
  border-radius: 22px;
  background: var(--surface);
  border-style: dashed;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}
.empty-state h2 { color: var(--text-strong); letter-spacing: -0.01em; }

/* App cards */
.card {
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
}
.card-thumb { border-bottom: 1px solid var(--border); }
.card-name { color: var(--text-strong); font-weight: 600; }

/* Templates */
.template-card {
  border-radius: 14px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: var(--accent);
}

/* === Modals === */
.modal-backdrop {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  background: rgba(11, 31, 58, 0.45);
}
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.55); }
.modal {
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
}
.modal h2 { color: var(--text-strong); letter-spacing: -0.01em; }

/* === Chat messages — replace hardcoded borders / colors === */
.msg.user {
  border-color: var(--accent-tint);
}
.msg.tool {
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .msg.tool {
  color: #c8d9c8;
  border-color: #2a3a30;
}
.msg.error {
  border-color: var(--error);
}

/* === Composer === */
.composer { background: var(--surface); }
.composer textarea { border-radius: 10px; }

/* === Pane tabs — accent on active === */
.pane-tab.active { color: var(--accent); }

/* === Loading bar — use accent === */
#loading-bar.active {
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 25%,
    var(--accent-2) 50%,
    var(--accent) 75%,
    transparent 100%
  );
  background-size: 300% 100%;
}

/* === Light mode comfort tweaks for IDE surfaces === */
html:not([data-theme="dark"]) .msg {
  background: var(--surface-2);
}
html:not([data-theme="dark"]) .msg.user {
  background: var(--accent-softer);
}
html:not([data-theme="dark"]) .messages {
  background: var(--bg-soft);
}

/* ============================================================
   Beany motion — adapted from Beany Logo Lab.
   Used by .msg.thinking, #empty-state, and the orbit overlay.
   ============================================================ */
@keyframes beany-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@keyframes beany-spin {
  to { transform: rotate(360deg); }
}
@keyframes beany-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* === Thinking message — chat-bubble style (Logo Lab "Typing" composition) === */
.msg.thinking {
  align-self: flex-start;
  background: transparent !important;
  border: none !important;
  padding: 4px 0 !important;
  border-radius: 0 !important;
  min-width: 0 !important;
  width: auto !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-end !important;
  gap: 10px !important;
}
.msg.thinking .beany-icon {
  width: 32px;
  height: 35px;
  flex-shrink: 0;
  animation: beany-bob 2.4s ease-in-out infinite;
}
.msg.thinking .typing-cluster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.msg.thinking .typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 2px 6px rgba(11,31,58,0.04);
}
.msg.thinking .thinking-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.msg.thinking .dots { display: inline-flex; gap: 4px; }
.msg.thinking .dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  display: inline-block;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.msg.thinking .dots span:nth-child(1) { animation-delay: 0s; }
.msg.thinking .dots span:nth-child(2) { animation-delay: 0.15s; }
.msg.thinking .dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    background: var(--text-faint); }
  30%           { transform: translateY(-4px); background: var(--accent); }
}
.msg.thinking .thinking-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding-left: 6px;
}

/* === Empty state on list page — large bobbing Beany + thought bubbles === */
.empty-state .empty-beany {
  position: relative;
  width: 168px;
  height: 156px;
  margin: 4px auto 18px;
}
.empty-state .empty-illu {
  width: 132px;
  height: 146px;
  display: block;
  margin: 0 auto;
  animation: beany-bob 2.6s ease-in-out infinite;
  filter: drop-shadow(0 12px 24px var(--accent-glow));
}
/* Thought bubble cluster — three popping bubbles next to Beany's head */
.empty-state .thought {
  position: absolute;
  right: -4px;
  top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.empty-state .thought .bubble {
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
}
.empty-state .thought .bubble.b1 {
  width: 8px;  height: 8px;
  opacity: 0;
  animation: thought-pop 1.6s ease-in-out infinite;
}
.empty-state .thought .bubble.b2 {
  width: 12px; height: 12px;
  opacity: 0;
  animation: thought-pop 1.6s ease-in-out 0.2s infinite;
}
.empty-state .thought .bubble.b3 {
  width: 38px; height: 38px;
  border-radius: 18px 18px 18px 6px;
  padding: 0 8px;
  opacity: 0;
  animation: thought-pop 1.6s ease-in-out 0.4s infinite;
}
.empty-state .thought .inner-dots {
  display: inline-flex;
  gap: 3px;
}
.empty-state .thought .inner-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  animation: thought-dot 1s ease-in-out infinite;
}
.empty-state .thought .inner-dots span:nth-child(2) { animation-delay: 0.15s; }
.empty-state .thought .inner-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes thought-pop {
  0%, 100%   { opacity: 0; transform: scale(0.6); }
  25%, 70%   { opacity: 1; transform: scale(1); }
}
@keyframes thought-dot {
  0%, 100% { transform: translateY(0);    opacity: 0.4; }
  50%      { transform: translateY(-3px); opacity: 1; }
}

/* === Trail loader (pulse trail) — supplementary motion under orbit caption === */
.trail-dots {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}
.trail-dots .pip {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  animation: trail-pulse 1.2s ease-in-out infinite;
}
.trail-dots .pip:nth-child(2) { animation-delay: 0.15s; }
.trail-dots .pip:nth-child(3) { animation-delay: 0.30s; }
.trail-dots .pip:nth-child(4) { animation-delay: 0.45s; }
@keyframes trail-pulse {
  0%, 100% { transform: scale(0.8); background: var(--accent-soft); }
  50%      { transform: scale(1.2); background: var(--accent); }
}

/* === Orbit loader (full-screen overlay) === */
.orbit-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(11, 31, 58, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
}
html[data-theme="dark"] .orbit-overlay { background: rgba(0, 0, 0, 0.6); }
.orbit-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  color: #fff;
}
.orbit {
  position: relative;
  width: 160px;
  height: 160px;
}
.orbit-beany {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  animation: beany-pulse 1.6s ease-in-out infinite;
}
.orbit-ring {
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 50%;
  animation: beany-spin 1.4s linear infinite;
}
.orbit-ring.r2 {
  inset: 12px;
  border-top-color: var(--sky);
  border-right-color: transparent;
  border-bottom-color: var(--accent);
  animation-duration: 2.2s;
  animation-direction: reverse;
}
.orbit-caption {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #fff;
  opacity: 0.88;
}
