/* ── USAGE WIDGET (sidebar bottom) ── */
.usage-widget {
  padding: 14px 16px;
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
}
.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
}
.usage-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.usage-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.usage-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 6px;
}
.usage-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.4s ease, background 0.4s;
  width: 0%;
}
.usage-fill.warn { background: #e8a020; }
.usage-fill.full { background: #e05050; }
.usage-reset {
  font-size: 10px;
  color: var(--ink-faint);
}

/* ── FEEDBACK BAR ── */
.feedback-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 0 0 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-dim);
  flex-wrap: wrap;
}
.feedback-bar.show { display: flex; }
.fb-question { flex: 1; min-width: 140px; font-weight: 500; }
.fb-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  font-family: var(--font-b);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.fb-btn:hover  { transform: translateY(-1px); }
.fb-btn:active { transform: translateY(0); }
.fb-btn.fb-yes { background: var(--mint-dim);  border-color: var(--mint-mid); color: var(--mint); }
.fb-btn.fb-yes:hover { background: var(--mint-mid); }
.fb-btn.fb-no  { background: var(--rose-dim);  border-color: var(--rose-mid); color: var(--rose); }
.fb-btn.fb-no:hover  { background: var(--rose-mid); }

/* ── CLOSED CONVERSATION ── */
.conv-closed-msg {
  display: none;
  padding: 14px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
  border-top: 1px solid var(--border-2);
}
.conv-closed-msg.show { display: block; }

/* ── HISTORY FEEDBACK DOT ── */
.hist-fb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 2px;
}
.hist-fb-dot.fb-resolved     { background: var(--mint); }
.hist-fb-dot.fb-not-resolved { background: var(--rose); }

/* ── LIMIT BANNER (above input) ── */
.limit-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 0 4px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}
.limit-banner.warn {
  display: flex;
  background: #3a2a00;
  border: 1px solid #6a4500;
  color: #e8a020;
}
.limit-banner.full {
  display: flex;
  background: #2e1010;
  border: 1px solid #6a2020;
  color: #e05050;
}

/* ── TWEAKS PANEL ── */
.tweaks-panel {
  display: none;
  position: fixed;
  bottom: 24px; right: 24px;
  width: 248px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 9999;
  font-family: var(--font-b);
  font-size: 13px;
  color: var(--ink);
  animation: panelIn 0.25s cubic-bezier(.34,1.56,.64,1) both;
}
.tweaks-panel.open { display: block; }
@keyframes panelIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.tw-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.tw-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.tw-close {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--ink-dim);
  transition: background 0.15s;
  /* button reset (was a div before) */
  padding: 0;
  font-family: var(--font-b);
  line-height: 1;
}
.tw-close:hover { background: var(--border); }

.tw-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-dim);
  margin-bottom: 8px;
}
.tw-row { margin-bottom: 16px; }

.tw-swatches { display: flex; gap: 6px; }
.tw-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.18s, border-color 0.18s;
  /* button reset (was a div before) — bg comes from inline style */
  padding: 0;
}
.tw-swatch:hover  { transform: scale(1.15); }
.tw-swatch.active { border-color: var(--ink); }

.tw-modes { display: flex; gap: 6px; }
.tw-mode-btn {
  flex: 1; padding: 8px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-dim);
  cursor: pointer;
  font-family: var(--font-b);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tw-mode-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-mid);
}

/* tournament mode toggle inside tweaks panel */
.tw-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.tw-toggle-hint {
  font-size: 11.5px; color: var(--ink-dim); line-height: 1.35;
  flex: 1;
}
.tw-toggle {
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s;
  padding: 0;
}
.tw-toggle .tw-toggle-knob {
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.18s, background 0.18s;
}
.tw-toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}
.tw-toggle.on .tw-toggle-knob {
  transform: translateX(16px);
  background: white;
}
.tw-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── TOASTS ── */
.toast-container {
  position: fixed;
  top: 64px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 10000;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 10px 14px;
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  min-width: 240px;
  max-width: 360px;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.18s, transform 0.22s cubic-bezier(.34,1.56,.64,1);
}
.toast.in  { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateX(12px); }

.toast::before {
  content: '';
  width: 3px; height: 100%;
  border-radius: 4px;
  align-self: stretch;
  background: var(--ink-dim);
  flex-shrink: 0;
}
.toast-error::before   { background: var(--rose); }
.toast-success::before { background: var(--mint); }
.toast-info::before    { background: var(--accent); }

.toast-msg { flex: 1; }
.toast-retry {
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 600;
  font-family: var(--font-b);
  cursor: pointer;
  transition: background 0.15s;
}
.toast-retry:hover { background: var(--accent-mid); }
.toast-close {
  background: transparent;
  border: 0;
  font-size: 18px; line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}
.toast-close:hover { color: var(--ink); }

@media (max-width: 680px) {
  .toast-container { top: 60px; right: 8px; left: 8px; }
  .toast { min-width: 0; max-width: none; }
}

/* ── CHAT TOOLBAR (top of the chat area, only when a conv is loaded) ── */
.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 10px 40px 0;
  flex-shrink: 0;
}
.chat-toolbar[hidden] { display: none; }
.chat-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  font-family: var(--font-b);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chat-tool-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-faint);
}
@media (max-width: 680px) {
  .chat-toolbar { padding: 8px 14px 0; }
}

/* ── SHARE MODAL ── */
.share-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
  animation: fadeIn 0.18s ease both;
}
.share-modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.share-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: panelIn 0.22s cubic-bezier(.34,1.56,.64,1) both;
}
.share-modal h3 {
  font-family: var(--font-d);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--ink);
}
.share-modal-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin: 0 0 22px;
}
.share-modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-b);
  transition: background 0.15s;
}
.share-modal-close:hover { background: var(--border); color: var(--ink); }

.share-url-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 11px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  margin-bottom: 14px;
  user-select: all;
}
.share-url-input:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.share-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.share-action {
  padding: 9px 16px;
  border-radius: 8px;
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s, transform 0.12s;
}
.share-action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  filter: drop-shadow(0 3px 10px var(--accent-mid));
}
.share-action.primary:hover { transform: translateY(-1px); }
.share-action.danger {
  background: var(--rose-dim);
  border-color: var(--rose-mid);
  color: var(--rose);
}
.share-action.danger:hover { background: var(--rose-mid); }
.share-action:disabled { opacity: 0.5; cursor: default; transform: none; filter: none; }
