*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  margin: 0;
}

.layout-grid,
.layout-grid > * {
  min-width: 0;
}

.card,
.left-rail,
main {
  width: 100%;
}

/* ===== Accent bar (compact, one row) ===== */
.accent-bar{
  display:flex;
  gap:.25rem;
  align-items:center;
  overflow-x:auto;
  white-space:nowrap;
  padding:.25rem .35rem;
  border:1px solid var(--card-border, #2a2f45);
  border-radius:.6rem;
  background:var(--surface-raised, #1e2333);
}
.accent-bar::-webkit-scrollbar{ height:6px }
.accent-bar::-webkit-scrollbar-thumb{ background:var(--card-border, #2a2f45); border-radius:6px }
.accent-sep{
  display:inline-block;
  width:1px;
  height:1rem;
  background:var(--card-border, #2a2f45);
  margin:0 .25rem;
}
.accent-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:1.6rem;
  height:1.8rem;
  padding:0 .35rem;
  font-size:.9rem;
  line-height:1;
  border:1px solid var(--card-border, #2a2f45);
  background:var(--surface, #1a1f2e);
  color:var(--text-primary, #e2e8f0);
  border-radius:.45rem;
  box-shadow:0 1px 0 rgba(0,0,0,.1);
  transition: background-color .12s ease, transform .02s ease;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.accent-btn:hover{ background:var(--surface-raised, #1e2333) }
.accent-btn:active{ transform: translateY(1px) }
.accent-btn:focus{ outline:2px solid rgba(99,102,241,0.4); outline-offset:2px }

/* ========================================================
   Conversation "Chat Bubble" Styling
   ======================================================== */

/* --- Default state: bubbles hidden when empty --- */
.conversation-messages {
  display: none;
}

/* --- Active conversation: integrated chat layout --- */
.notebook-editor.conversation-active {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--card-border, #2a2f45);
  border-radius: 0.75rem;
  background: var(--surface, #1a1f2e);
  overflow: hidden;
  height: 24rem;
}

.notebook-editor.conversation-active .conversation-messages {
  display: block;
  padding: 1rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.notebook-editor.conversation-active textarea {
  border: none;
  border-top: 1px solid var(--card-border, #2a2f45);
  border-radius: 0;
  resize: none;
  height: 4.5rem;
  min-height: 3.5rem;
  flex: 0 0 auto;
}

.notebook-editor.conversation-active textarea:focus {
  box-shadow: none;
  outline: none;
  ring: none;
}

/* --- Bubble styles --- */
.conversation-message {
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.65rem;
  border-radius: 0.5rem;
  animation: slideIn 0.3s ease;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.conversation-message:last-child {
  margin-bottom: 0;
}

.conversation-message .conversation-role {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
  opacity: 0.7;
}

.conversation-message.assistant {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid #6366f1;
  margin-right: 2.5rem;
  color: #c7d2fe;
}

.conversation-message.user {
  background: rgba(34, 197, 94, 0.1);
  border-left: 3px solid #22c55e;
  margin-left: 2.5rem;
  color: #bbf7d0;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Conversation floating send button ===== */
.notebook-editor{
  position:relative;
}
/* Conversation mic button */
.conversation-mic-btn{
  position:absolute;
  z-index:30;
  background:linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color:#fff;
  border-radius:999px;
  width:2.75rem;
  height:2.75rem;
  right:calc(2.75rem + 12px);
  bottom:6px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,0.2);
  box-shadow:0 8px 18px rgba(22,163,74,0.3);
  transition:transform .12s ease, box-shadow .12s ease, background .15s ease;
  padding:0;
  cursor:pointer;
}
.conversation-mic-btn.hidden{display:none}
.conversation-mic-btn:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 20px rgba(22,163,74,0.35);
}
.conversation-mic-btn.recording{
  background:linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow:0 8px 18px rgba(220,38,38,0.3);
  animation:micPulse 1.5s ease-in-out infinite;
}
@keyframes micPulse{
  0%,100%{transform:scale(1)}
  50%{transform:scale(1.08)}
}
.conversation-mic-icon{
  width:1.2rem;
  height:1.2rem;
  display:block;
  flex-shrink:0;
}
#btnConversationContinueFloating{
  position:absolute;
  z-index:30;
  background:linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
  color:#fff;
  border-radius:999px;
  width:2.75rem;
  height:2.75rem;
  right:0.85rem;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  border:1px solid rgba(255, 255, 255, 0.2);
  box-shadow:0 8px 18px rgba(67, 56, 202, 0.3);
  transition:transform .12s ease, box-shadow .12s ease;
  pointer-events:auto;
}
#btnConversationContinueFloating.hidden{
  display:none;
}
.conversation-close{
  position:absolute;
  top:-0.35rem;
  right:-0.35rem;
  width:1.1rem;
  height:1.1rem;
  border-radius:999px;
  background:#111827;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.75rem;
  line-height:1;
  box-shadow:0 2px 6px rgba(0,0,0,0.2);
}
#btnConversationContinueFloating:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 20px rgba(67, 56, 202, 0.35);
}
#btnConversationContinueFloating:active{
  transform:translateY(0);
}
.conversation-send-icon{
  width:1.2rem;
  height:1.2rem;
  transform:scaleX(-1);
  transform-origin:center;
  transform-box: fill-box;
  display:block;
  flex-shrink:0;
}

@media (max-width: 640px) {
  #btnConversationContinueFloating{
    width:3.25rem;
    height:3.25rem;
    box-shadow:0 10px 24px rgba(67, 56, 202, 0.35);
  }
  .conversation-send-icon{
    width:1.5rem;
    height:1.5rem;
  }
  .conversation-close{
    width:1.35rem;
    height:1.35rem;
    font-size:0.95rem;
  }
}

@media (pointer: coarse) {
  #btnConversationContinueFloating{
    width:3.25rem;
    height:3.25rem;
  }
  .conversation-send-icon{
    width:1.5rem;
    height:1.5rem;
  }
}

/* ===== Free / AI tier badges on tool tabs ===== */
.wif-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  padding: 1.5px 5px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 3px;
  flex-shrink: 0;
}
.wif-badge-free {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.wif-badge-ai {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.2);
}
/* Badge inside Add-Vocab sub-tabs & AP tabs (light theme) */
.av-btn .wif-badge,
#ap-panel .wif-badge {
  font-size: 0.5rem;
  padding: 1px 4px;
}
.av-btn .wif-badge-free,
#ap-panel .wif-badge-free {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.2);
}
.av-btn .wif-badge-ai,
#ap-panel .wif-badge-ai {
  background: rgba(147, 51, 234, 0.08);
  color: #9333ea;
  border-color: rgba(147, 51, 234, 0.15);
}
/* Hide badges for pro users (prompt-gate.js adds this class to body) */
body.wif-pro .wif-badge { display: none; }

/* ===== Universal Loading Spinner Animation ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}
