/* ============================================================
  AVB Planning Poker — styles.css
  ============================================================ */

/* ---- Variables (light default, dark overrides) ------------ */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-fg: #ffffff;
  --primary-light: #ede9fe;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.1);

  /* Layer scale: keep a single source of truth for stacking order. */
  --z-base: 1;
  --z-sticky-header: 10;
  --z-calculator: 20;
  --z-history-fab: 30;
  --z-examples-fab: 31;
  --z-jira-prompt-fab: 32;
  --z-history-sidebar: 40;
  --z-examples-sidebar: 41;
  --z-jira-prompt-sidebar: 42;
  --z-demo-badge: 50;
  --z-modal: 100;
  --z-toast: 200;

  /* Local calculator stack (inside .calculator stacking context). */
  --z-calc-row-base: 1;
  --z-calc-row-active: 2;
  --z-calc-field-active: 3;
  --z-calc-button-base: 4;
  --z-overlay-popover: 90;
  --r: 8px;
  --r-lg: 14px;
  --font: 'Inter', system-ui, sans-serif;
}

[data-theme='dark'] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #0f172a;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-light: #1e1b4b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ---- Reset ------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition:
    background 0.2s,
    color 0.2s;
  line-height: 1.5;
}
a {
  color: var(--primary);
}
img,
svg {
  display: block;
  max-width: 100%;
}
input,
button,
select {
  font-family: inherit;
}

/* ---- View routing ---------------------------------------- */
.view {
  display: none;
}
.view.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}
.btn-primary.is-disabled:hover,
.btn-secondary.is-disabled:hover,
.btn-ghost.is-disabled:hover {
  transform: none;
  box-shadow: none;
}
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: var(--r);
  color: var(--text-muted);
  transition: background 0.15s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-pencil {
  display: inline-block;
  font-size: 0.74em;
  line-height: 1;
}

/* ---- Card ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

/* ---- Form ------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input {
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

/* ============================================================
   HOME VIEW
   ============================================================ */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-header);
}

.home-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  font-size: 1.5rem;
}
.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.home-main {
  flex: 1;
  padding: 48px 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero {
  text-align: center;
}
.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 10px;
  max-width: 520px;
  margin-inline: auto;
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: start;
}
.home-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  padding-top: 60px;
}
.home-divider span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--surface);
}
.create-card h2,
.join-card h2 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.create-card .btn,
.join-card .btn {
  width: 100%;
  margin-top: 4px;
}

.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-dashboard[hidden] {
  display: none !important;
}
.admin-dashboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.admin-dashboard-head h2 {
  font-size: 1.05rem;
  margin-bottom: 2px;
}
.admin-history-count,
.admin-history-empty {
  font-size: 0.84rem;
  color: var(--text-muted);
}
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.admin-history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}
.admin-history-table th,
.admin-history-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.82rem;
}
.admin-history-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--surface-2);
}
.admin-history-table tbody tr:last-child td {
  border-bottom: none;
}

.formula-preview {
  max-width: 900px;
}
.formula-preview summary {
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 0;
}
.formula-preview summary:hover {
  color: var(--text);
}
.formula-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.formula-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.formula-label {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  min-width: 44px;
  text-align: center;
}
.formula-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================================
   LOADING
   ============================================================ */
#view-loading {
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   GAME VIEW
   ============================================================ */
#view-game {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
#view-game.active {
  display: flex;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}
.game-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.game-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.game-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.story-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.story-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.story-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-value--editable {
  cursor: pointer;
}
.story-value--editable:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
}

/* ---- Participants ----------------------------------------- */
.participants-section {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  flex-shrink: 0;
  overflow-x: auto;
}
.participants-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: 58px;
  align-items: flex-start;
}

/* Participant Card (3D Flip) */
.participant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  perspective: 700px;
  position: relative;
}
.p-card-inner {
  position: relative;
  width: 58px;
  height: 82px;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.p-card-inner.is-flipped {
  transform: rotateY(180deg);
}

.p-card-front,
.p-card-back {
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.p-card-front {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.p-card-front.unvoted {
  background: var(--surface-2);
  border: 2px dashed var(--border);
}
.p-card-back {
  transform: rotateY(180deg);
  background: var(--surface);
  border: 2px solid var(--border);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.p-card-back.vote-high {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}
.p-card-back.vote-med {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #d97706;
}
.p-card-back.vote-low {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.p-card-back.vote-ok {
  background: #f0fdf4;
  border-color: #86efac;
  color: #16a34a;
}
[data-theme='dark'] .p-card-back.vote-high {
  background: #450a0a;
  border-color: #991b1b;
  color: #fca5a5;
}
[data-theme='dark'] .p-card-back.vote-med {
  background: #451a03;
  border-color: #92400e;
  color: #fcd34d;
}
[data-theme='dark'] .p-card-back.vote-low {
  background: #172554;
  border-color: #1e40af;
  color: #93c5fd;
}
[data-theme='dark'] .p-card-back.vote-ok {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}

/* voted indicator on card front */
.card-voted-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.p-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 84px;
  text-align: center;
  color: var(--text-muted);
}
.p-name-text {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  max-width: 100%;
  word-break: break-word;
}
.you-badge {
  display: block;
  color: var(--primary);
  font-size: 0.64rem;
  line-height: 1;
}
.mod-badge {
  font-size: 0.75rem;
}

.p-ranking-strip {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -7px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px;
  border-radius: 6px;
  background: transparent;
  pointer-events: auto;
  z-index: 2;
  transform: rotateY(180deg);
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}

.p-ranking-strip.is-muted {
  filter: grayscale(0.45);
  opacity: 0.7;
}

.p-ranking-chip {
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4px;
  height: 7px;
  font-size: 0;
  font-weight: 700;
  line-height: 1;
  color: transparent;
  user-select: none;
  flex: 1 1 0;
}

.p-ranking-chip[class*='size-'] {
  width: 13px;
  min-width: 13px;
  height: 10px;
  border-radius: 3px;
  font-size: 8px;
  color: #0f172a;
  flex: 0 0 auto;
}

.p-ranking-chip:not([class*='size-']) {
  border-radius: 999px;
}

.p-ranking-chip.size-1 {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
}

.p-ranking-chip.size-2 {
  background: linear-gradient(180deg, #cffafe 0%, #a5f3fc 100%);
}

.p-ranking-chip.size-3 {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.p-ranking-chip.size-5 {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
}

.p-ranking-chip.size-8 {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
}

.p-ranking-chip.low {
  background: #6b7280;
}

.p-ranking-chip.medium {
  background: #f59e0b;
}

.p-ranking-chip.high {
  background: #dc2626;
}

.p-ranking-chip.unknown {
  background: #9ca3af;
}

/* ---- Status Bar ------------------------------------------ */
.status-bar {
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition:
    background 0.2s,
    color 0.2s;
}
.status-bar.status-ready {
  background: #f0fdf4;
  color: #16a34a;
}
.status-bar.status-ready .status-text::before {
  content: '✅ ';
}
[data-theme='dark'] .status-bar.status-ready {
  background: #052e16;
  color: #86efac;
}

/* ---- Tabs ------------------------------------------------- */
.game-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--surface-2);
}

.game-main > * {
  width: 100%;
  max-width: 940px;
  margin-left: auto;
  margin-right: auto;
}

/* Scrollbar styling */
.game-main::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.game-main::-webkit-scrollbar-track {
  background: var(--surface-2);
}

.game-main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
  border: 2px solid var(--surface-2);
}

.game-main::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.participants-section,
.session-history-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--surface-2);
}

.participants-section::-webkit-scrollbar,
.session-history-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.participants-section::-webkit-scrollbar-track,
.session-history-list::-webkit-scrollbar-track {
  background: var(--surface-2);
}

.participants-section::-webkit-scrollbar-thumb,
.session-history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
  border: 2px solid var(--surface-2);
}

.participants-section::-webkit-scrollbar-thumb:hover,
.session-history-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.voting-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ---- Vote Cards ------------------------------------------ */
.vote-cards-grid {
  display: flex;
  flex-wrap: wrap;
  column-gap: 10px;
  row-gap: 18px;
  justify-content: center;
  padding: 18px 20px 32px;
  align-content: flex-start;
}
.vote-card {
  width: 58px;
  height: 84px;
  border-radius: var(--r);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  pointer-events: auto;
}

.vote-card-value {
  display: inline-block;
  line-height: 1;
  pointer-events: auto;
}
.vote-card:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}
.vote-card.suggested-preview:not(:disabled):not(.selected) {
  border-color: var(--primary);
  background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}
.vote-card.suggested-preview:not(:disabled):not(.selected)::after {
  content: 'vote?';
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  opacity: 0.75;
  pointer-events: none;
}
.vote-card.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-8px);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

.vote-card.selected[data-value='0'] {
  animation: zero-vote-lethargic-spin 4.8s linear infinite;
}

/* One-shot gag for '?': panic wobble, duck behind, then settle. */
.vote-card.selected[data-value='?'] .vote-card-value.question-panic-enter {
  animation: question-panic-enter 1s linear 1 both;
  animation-delay: var(--one-shot-delay, 0ms);
}

/* One-shot gag for '☕': pour into a mouth emoji, then refill and settle. */
.vote-card.selected[data-value='☕'] .vote-card-value.coffee-pour-enter {
  position: relative;
  animation: coffee-pour-enter 1.3s cubic-bezier(0.22, 0.9, 0.2, 1) 1 both;
  animation-delay: var(--one-shot-delay, 0ms);
  transform-origin: 50% 80%;
}

/* Fun FX: high-point picks get a subtle shake + smoke accent. */
.vote-card.selected[data-value='13'],
.vote-card.selected[data-value='21'],
.vote-card.selected[data-value='34'],
.vote-card.selected[data-value='55'],
.vote-card.selected[data-value='89'] {
  animation: high-vote-shake 0.58s linear infinite;
  box-shadow:
    0 8px 20px rgba(124, 58, 237, 0.38),
    0 0 0 1px rgba(248, 113, 113, 0.25),
    0 0 16px rgba(248, 113, 113, 0.32);
}

.vote-card.selected[data-value='13'] {
  animation-duration: 0.66s;
}

.vote-card.selected[data-value='21'] {
  animation-duration: 0.52s;
}

.vote-card.selected[data-value='34'] {
  animation-duration: 0.4s;
}

.vote-card.selected[data-value='55'] {
  animation-duration: 0.3s;
}

.vote-card.selected[data-value='89'] {
  animation-duration: 0.2s;
}

.vote-card.selected[data-value='13']::before,
.vote-card.selected[data-value='21']::before,
.vote-card.selected[data-value='34']::before,
.vote-card.selected[data-value='55']::before,
.vote-card.selected[data-value='89']::before,
.vote-card.selected[data-value='13']::after,
.vote-card.selected[data-value='21']::after,
.vote-card.selected[data-value='34']::after,
.vote-card.selected[data-value='55']::after,
.vote-card.selected[data-value='89']::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 26px;
  height: 16px;
  border-radius: 999px;
  background: radial-gradient(
    circle at 50% 60%,
    rgba(255, 255, 255, 0.32) 0%,
    rgba(148, 163, 184, 0.2) 45%,
    transparent 75%
  );
  filter: blur(1.2px);
  opacity: 0;
  pointer-events: none;
}

.vote-card.selected[data-value='13']::before,
.vote-card.selected[data-value='21']::before,
.vote-card.selected[data-value='34']::before,
.vote-card.selected[data-value='55']::before,
.vote-card.selected[data-value='89']::before {
  left: 5px;
  animation: high-smoke-plume 1.9s ease-out infinite;
}

.vote-card.selected[data-value='13']::after,
.vote-card.selected[data-value='21']::after,
.vote-card.selected[data-value='34']::after,
.vote-card.selected[data-value='55']::after,
.vote-card.selected[data-value='89']::after {
  right: 5px;
  animation: high-smoke-plume 1.9s ease-out -0.95s infinite;
}

.vote-card:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---- Calculator ------------------------------------------ */
.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: stretch;
  flex: 0 0 auto;
  padding: 12px 14px;
  gap: 10px;
  position: relative;
  z-index: var(--z-calculator);
  transition: grid-template-columns 0.18s ease;
}

.calculator.calc-details-open {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.calc-inputs {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: fit-content(45%) minmax(0, 1fr);
  gap: 12px 10px;
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: visible;
}
.calc-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  row-gap: 12px;
  position: relative;
  z-index: var(--z-calc-row-base);
}

.calc-row:hover {
  z-index: var(--z-calc-row-active);
}

.calc-row:focus-within {
  z-index: var(--z-calc-row-active);
}
.calc-field {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  position: relative;
}

.calc-field:hover {
  z-index: var(--z-calc-field-active);
}

.calc-field:focus-within {
  z-index: var(--z-calc-field-active);
}
.calc-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  white-space: nowrap;
  min-width: 0;
}
.calc-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: normal;
  line-height: 1.3;
}

.scale-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  min-width: 0;
  width: 100%;
  justify-self: stretch;
}
.scale-btn {
  position: relative;
  z-index: var(--z-calc-button-base);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  padding: 8px 4px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  min-width: 0;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.12s;
}
.scale-btn:hover {
  border-color: var(--primary);
  color: var(--text);
  transform: translateY(-1px);
}
.scale-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}
.scale-btn.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Fun FX: any selected High (non-size) factor gets mild shake + smoke. */
.scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3'] {
  animation: high-factor-shake 0.52s ease-in-out infinite;
  box-shadow:
    0 3px 12px rgba(248, 113, 113, 0.28),
    inset 0 -1px 0 rgba(2, 6, 23, 0.2);
}

.scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::before,
.scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::after {
  content: '';
  position: absolute;
  bottom: -1px;
  width: 22px;
  height: 13px;
  border-radius: 999px;
  background: radial-gradient(
    circle at 50% 60%,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(148, 163, 184, 0.18) 48%,
    transparent 75%
  );
  filter: blur(1.1px);
  opacity: 0;
  pointer-events: none;
}

.scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::before {
  left: 2px;
  animation: high-smoke-plume 1.7s ease-out infinite;
}

.scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::after {
  right: 2px;
  animation: high-smoke-plume 1.7s ease-out -0.85s infinite;
}

@keyframes high-factor-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  25% {
    transform: translateX(-1px) rotate(-0.7deg);
  }
  50% {
    transform: translateX(1px) rotate(0.7deg);
  }
  75% {
    transform: translateX(-0.6px) rotate(-0.45deg);
  }
}

@keyframes high-vote-shake {
  0%,
  100% {
    transform: translateY(-8px) translateX(0) rotate(0deg);
  }
  25% {
    transform: translateY(-8px) translateX(-1.1px) rotate(-0.7deg);
  }
  50% {
    transform: translateY(-8px) translateX(1.1px) rotate(0.7deg);
  }
  75% {
    transform: translateY(-8px) translateX(-0.7px) rotate(-0.45deg);
  }
}

@keyframes zero-vote-lethargic-spin {
  0% {
    transform: translateY(-8px) rotate(0deg);
  }
  100% {
    transform: translateY(-8px) rotate(360deg);
  }
}

@keyframes question-panic-enter {
  0% {
    transform: translate(0, 0);
  }
  12.5% {
    transform: translate(-11px, -14px);
  }
  25% {
    transform: translate(-13px, 0);
  }
  37.5% {
    transform: translate(-11px, 14px);
  }
  50% {
    transform: translate(0, -14px);
  }
  62.5% {
    transform: translate(11px, 14px);
  }
  75% {
    transform: translate(13px, 0);
  }
  87.5% {
    transform: translate(11px, -14px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes coffee-pour-enter {
  0% {
    transform: rotate(0deg);
  }
  45% {
    transform: rotate(360deg);
  }
  85% {
    transform: rotate(720deg);
  }
  91% {
    transform: rotate(-3deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes high-smoke-plume {
  0% {
    transform: translateY(0) scale(0.65);
    opacity: 0;
  }
  15% {
    opacity: 0.34;
  }
  65% {
    opacity: 0.2;
  }
  100% {
    transform: translateY(-18px) scale(1.35);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vote-card.selected[data-value='☕'] .vote-card-value.coffee-pour-enter,
  .vote-card.selected[data-value='?'] .vote-card-value.question-panic-enter,
  .vote-card.selected[data-value='0'],
  .scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3'],
  .vote-card.selected[data-value='13'],
  .vote-card.selected[data-value='21'],
  .vote-card.selected[data-value='34'],
  .vote-card.selected[data-value='55'],
  .vote-card.selected[data-value='89'] {
    animation: none;
  }

  .scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::before,
  .scale-buttons:not(.size-scale) .scale-btn.is-selected[data-value='3']::after,
  .vote-card.selected[data-value='13']::before,
  .vote-card.selected[data-value='21']::before,
  .vote-card.selected[data-value='34']::before,
  .vote-card.selected[data-value='55']::before,
  .vote-card.selected[data-value='89']::before,
  .vote-card.selected[data-value='13']::after,
  .vote-card.selected[data-value='21']::after,
  .vote-card.selected[data-value='34']::after,
  .vote-card.selected[data-value='55']::after,
  .vote-card.selected[data-value='89']::after {
    animation: none;
    opacity: 0;
  }
}

.calc-popover {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #1e293b;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.74rem;
  line-height: 1.35;
  text-align: left;
  white-space: pre-line;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: var(--z-overlay-popover);
  transform: translateY(-6px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease,
    visibility 0s linear 0.14s;
}

.calc-popover.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease,
    visibility 0s;
}

.calc-popover.is-above {
  transform: translateY(6px);
}

[data-theme='light'] .calc-popover {
  border-color: #334155;
}

[data-theme='dark'] .calc-popover {
  border-color: #475569;
  background: #020617;
}

/* Size scale gets a distinct visual language from the other factor buttons. */
.scale-buttons.size-scale {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 0% 50%, rgba(56, 189, 248, 0.08), transparent 46%),
    radial-gradient(circle at 100% 50%, rgba(251, 191, 36, 0.12), transparent 48%), var(--surface-2);
}

.calc-inputs.calc-compact-buttons .scale-buttons {
  grid-template-columns: repeat(3, minmax(30px, 1fr));
  gap: 6px;
}

.calc-inputs.calc-compact-buttons .scale-buttons.size-scale {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
}

.calc-inputs.calc-compact-buttons .scale-btn {
  padding: 7px 2px;
  font-size: 0.76rem;
}

/* Medium/Med label switching */
.btn-label-short {
  display: none;
}
.calc-inputs.calc-compact-buttons .btn-label-full {
  display: none;
}
.calc-inputs.calc-compact-buttons .btn-label-short {
  display: inline;
}

.size-scale .scale-btn {
  border-width: 1px;
  border-radius: 999px;
  color: #0f172a;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

.size-scale .scale-btn[data-value='1'] {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
}

.size-scale .scale-btn[data-value='2'] {
  background: linear-gradient(180deg, #cffafe 0%, #a5f3fc 100%);
}

.size-scale .scale-btn[data-value='3'] {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.size-scale .scale-btn[data-value='5'] {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
}

.size-scale .scale-btn[data-value='8'] {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
}

.size-scale .scale-btn:hover:not(.is-selected) {
  border-color: #64748b;
  transform: translateY(-1px) scale(1.02);
}

.size-scale .scale-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.28);
}

.size-scale .scale-btn.is-selected {
  border-color: var(--primary);
  background: linear-gradient(180deg, #334155 0%, #0f172a 100%);
  color: #f8fafc;
  box-shadow:
    0 0 0 2px rgba(124, 58, 237, 0.48),
    0 7px 14px rgba(15, 23, 42, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

[data-theme='dark'] .scale-buttons.size-scale {
  border-color: #475569;
  background:
    radial-gradient(circle at 0% 50%, rgba(56, 189, 248, 0.16), transparent 50%),
    radial-gradient(circle at 100% 50%, rgba(251, 191, 36, 0.2), transparent 52%),
    linear-gradient(180deg, #0b1220 0%, #111827 100%);
}

[data-theme='dark'] .size-scale .scale-btn {
  color: #0b1220;
}

[data-theme='dark'] .size-scale .scale-btn.is-selected {
  border-color: var(--primary);
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #e0f2fe;
  box-shadow:
    0 0 0 2px rgba(139, 92, 246, 0.58),
    0 8px 16px rgba(2, 132, 199, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.calc-output {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-width: 220px;
}

#calc-details {
  order: 1;
}

.calc-output > .calc-result-grid {
  order: 2;
  grid-template-columns: max-content;
  justify-content: center;
}

#btn-vote-calc {
  order: 3;
}

#btn-toggle-calc-details {
  order: 4;
}
.calc-result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.calc-result-grid-advanced {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.calc-result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1.5px solid var(--border);
  text-align: center;
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}
.calc-result-item:hover {
  background: var(--surface-2);
  border-color: var(--text-muted);
}
.calc-result-item.highlight {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.08);
  width: max-content;
  min-width: min(210px, 100%);
}
.calc-result-item.highlight:hover {
  background: rgba(124, 58, 237, 0.12);
}
.result-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.result-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}
.formula-value {
  font-family: monospace;
  font-size: 1rem;
}
.sp-big {
  font-size: 2rem;
  color: var(--primary);
}
.result-range {
  font-size: 0.68rem;
  color: var(--text-muted);
}
#btn-vote-calc {
  align-self: center;
  margin-top: 4px;
  padding: 8px 16px;
}

.btn-calc-toggle {
  align-self: center;
  min-width: 0;
  margin-top: -6px;
  padding: 5px 10px;
  font-size: 0.74rem;
  line-height: 1.1;
}

.calc-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calc-details[hidden] {
  display: none;
}

.factor-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.factor-chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  text-align: center;
}
.factor-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.factor-math {
  display: block;
  margin-top: 3px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.fibonacci-section {
  position: relative;
  z-index: var(--z-base);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.fibonacci-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 20px;
}

/* ---- Results --------------------------------------------- */
.results-area {
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  padding: 16px;
  flex-shrink: 0;
}
.results-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.results-votes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.result-vote-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 30px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-size: 0.875rem;
}
.result-vote-chip .rv-name {
  font-weight: 500;
  color: var(--text-muted);
}
.result-vote-chip .rv-val {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}
.results-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.stat-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.results-decision {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.results-decision-top {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 12px;
}

#btn-copy-audit {
  margin-left: auto;
}

.results-final-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.results-final-value.is-empty {
  color: var(--text-muted);
}

.results-final-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.results-final-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decision-chip {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.decision-chip:hover {
  border-color: var(--primary);
}

.decision-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}

.decision-chip.suggested {
  border-color: var(--primary);
  background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}

.decision-chip.clear-chip {
  color: var(--text-muted);
}

.history-sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  width: min(320px, 86vw);
  padding: 12px;
  border-right: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(0);
  transition: transform 0.18s ease;
  z-index: var(--z-history-sidebar);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-fab {
  position: fixed;
  top: 66px;
  left: 12px;
  z-index: var(--z-history-fab);
  box-shadow: var(--shadow);
}

.examples-fab {
  position: fixed;
  top: 66px;
  right: 12px;
  z-index: var(--z-examples-fab);
  box-shadow: var(--shadow);
}

.jira-prompt-fab {
  position: fixed;
  top: 102px;
  right: 12px;
  z-index: var(--z-jira-prompt-fab);
  box-shadow: var(--shadow);
}

.history-sidebar.is-collapsed {
  transform: translateX(-102%);
}

.history-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.history-collapse-btn {
  font-size: 1rem;
  padding: 4px 8px;
}

.session-history-empty {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.session-history-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.examples-sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: min(360px, 88vw);
  padding: 12px;
  border-left: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(0);
  transition: transform 0.18s ease;
  z-index: var(--z-examples-sidebar);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.examples-sidebar.is-collapsed {
  transform: translateX(102%);
}

.jira-prompt-sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: min(360px, 88vw);
  padding: 12px;
  border-left: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(0);
  transition: transform 0.18s ease;
  z-index: var(--z-jira-prompt-sidebar);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jira-prompt-sidebar.is-collapsed {
  transform: translateX(102%);
}

.examples-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.examples-sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.examples-collapse-btn {
  font-size: 1rem;
  padding: 4px 8px;
}

.examples-sidebar-subtitle {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.jira-prompt-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.jira-prompt-sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
}

.jira-prompt-collapse-btn {
  font-size: 1rem;
  padding: 4px 8px;
}

.jira-prompt-sidebar-subtitle {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: italic;
}

.feedback-link {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

.feedback-link:visited {
  color: var(--text-muted);
}

.feedback-link:hover,
.feedback-link:focus-visible {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.7;
}

.jira-prompt-feedback {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.jira-prompt-feedback a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.jira-prompt-feedback a:hover,
.jira-prompt-feedback a:focus-visible {
  color: var(--text);
}

.jira-prompt-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.jira-prompt-copy-row {
  display: flex;
  justify-content: flex-end;
}

.jira-prompt-paste-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 2px;
  min-height: 0;
}

.jira-paste-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.jira-paste-input {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  line-height: 1.4;
  resize: none;
  min-height: 0;
  transition: border-color 0.15s;
}

.jira-paste-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.jira-paste-input.is-applied {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.jira-prompt-text {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.4;
  resize: none;
  min-height: 0;
}

.jira-prompt-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.examples-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.examples-group {
  display: grid;
  gap: 8px;
}

.examples-group-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 800;
}

.example-entry {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition:
    border-color 0.14s ease,
    background 0.14s ease,
    transform 0.12s ease,
    box-shadow 0.14s ease;
}

.example-entry:hover {
  border-color: rgba(124, 58, 237, 0.55);
  transform: translateY(-1px);
}

.example-entry.is-selected {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.1);
  box-shadow:
    inset 3px 0 0 var(--primary),
    inset 0 0 0 1px rgba(124, 58, 237, 0.2);
}

.example-entry-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text);
}

.example-entry-ratings {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.example-label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  font-weight: 700;
}

.example-text {
  font-size: 0.76rem;
  color: var(--text);
  line-height: 1.35;
}

.history-entry {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 8px 9px;
  display: grid;
  gap: 4px;
}

.history-entry-title {
  font-size: 0.84rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry-story {
  font-weight: 800;
}

.history-entry-sep {
  color: var(--text-muted);
}

.history-entry-sp {
  font-weight: 800;
  color: var(--primary);
}

.history-entry-meta,
.history-entry-votes {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
  word-break: break-word;
}

@media (max-width: 768px) {
  .history-fab {
    top: 60px;
    left: 8px;
  }

  .examples-fab {
    top: 60px;
    right: 8px;
  }

  .jira-prompt-fab {
    top: 100px;
    right: 8px;
  }

  .history-sidebar {
    top: 58px;
    width: min(300px, 90vw);
  }

  .examples-sidebar {
    top: 58px;
    width: min(320px, 92vw);
  }

  .jira-prompt-sidebar {
    top: 58px;
    width: min(320px, 92vw);
  }
}

/* ---- Footer ---------------------------------------------- */
.game-footer {
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  padding: 10px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-section[hidden] {
  display: none;
}

#footer-voting .vote-count {
  margin-left: 8px;
}

#btn-reveal,
#btn-next-story {
  width: 132px;
  padding: 10px 20px;
}

.vote-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}
.muted-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Modal ----------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] {
  display: none;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-box h3 {
  font-size: 1rem;
  font-weight: 700;
}
.modal-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  width: 100%;
}
.modal-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Toast ----------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: var(--z-toast);
  background: #1e293b;
  color: #e2e8f0;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast[hidden] {
  display: none;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-success {
  background: #065f46;
  color: #a7f3d0;
}
.toast.toast-error {
  background: #7f1d1d;
  color: #fca5a5;
}
.toast.toast-info {
  background: #1e3a5f;
  color: #93c5fd;
}

/* ---- Demo mode badge ------------------------------------- */
.demo-mode-badge {
  position: fixed;
  top: 66px;
  right: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #451a03;
  color: #fcd34d;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #92400e;
  z-index: var(--z-demo-badge);
  box-shadow: var(--shadow);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Keep calculator two-column longer; stack only on narrower screens */
@media (max-width: 900px) {
  .calculator {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* ---- Tablet/Large Mobile (900px - 1180px) ---- */
@media (max-width: 900px) {
  .home-main {
    padding: 32px 16px;
    gap: 24px;
  }
  .vote-cards-grid {
    padding: 16px 16px 24px;
    column-gap: 8px;
    row-gap: 16px;
  }
  .vote-card {
    width: 54px;
    height: 80px;
    font-size: 1.1rem;
  }
  .participants-grid {
    gap: 12px;
    min-height: 68px;
  }
  .participant-card {
    gap: 6px;
  }
  .p-card-inner {
    width: 52px;
    height: 76px;
  }
  .p-ranking-strip {
    bottom: -6px;
  }
  .p-ranking-chip {
    width: 3px;
    height: 6px;
  }
  .p-ranking-chip[class*='size-'] {
    width: 11px;
    min-width: 11px;
    height: 9px;
    font-size: 7px;
  }
  .p-name {
    max-width: 64px;
    font-size: 0.68rem;
  }
  .game-header {
    padding: 8px 16px;
    min-height: 52px;
  }
  .session-title {
    max-width: 120px;
    font-size: 0.9rem;
  }
  .story-value {
    max-width: 200px;
    font-size: 0.9rem;
  }
  .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  .scale-buttons {
    grid-template-columns: repeat(3, minmax(36px, 1fr));
    gap: 6px;
  }
  .scale-buttons.size-scale {
    grid-template-columns: repeat(5, minmax(36px, 1fr));
  }
  .scale-btn {
    padding: 8px 4px;
    font-size: 0.84rem;
  }
  .calc-result-grid {
    gap: 10px;
  }
  .calc-result-grid-advanced {
    grid-template-columns: 1fr;
  }
  .calc-result-item {
    padding: 10px 6px;
  }
  .result-value {
    font-size: 1.2rem;
  }
  .sp-big {
    font-size: 1.8rem;
  }
  .result-label {
    font-size: 0.68rem;
  }
  .factor-breakdown {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .factor-chip {
    padding: 8px 8px;
  }
  .factor-name {
    font-size: 0.65rem;
  }
}

/* ---- Medium Mobile (680px - 900px) ---- */
@media (max-width: 680px) {
  .home-cards {
    grid-template-columns: 1fr;
  }
  .home-divider {
    padding: 8px 0;
    flex-direction: row;
  }
  .home-divider span {
    width: 100%;
    text-align: center;
  }
  .hero h1 {
    font-size: 1.5rem;
  }
  .hero-sub {
    font-size: 0.9rem;
  }
  .home-main {
    padding: 24px 14px;
    gap: 20px;
  }
  .game-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    min-height: auto;
  }
  .game-header-left {
    gap: 8px;
  }
  .game-header-center {
    order: 3;
    width: 100%;
    padding-top: 6px;
  }
  .game-header-right {
    gap: 6px;
  }
  .session-title {
    max-width: 80px;
    font-size: 0.85rem;
  }
  .story-label {
    font-size: 0.7rem;
  }
  .story-value {
    max-width: 140px;
    font-size: 0.85rem;
  }
  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .btn-sm {
    padding: 5px 8px;
    font-size: 0.72rem;
  }
  .icon-btn {
    font-size: 0.95rem;
    padding: 4px 6px;
  }
  .participants-grid {
    gap: 10px;
    min-height: 64px;
    padding: 8px 0;
  }
  .participant-card {
    gap: 4px;
  }
  .p-card-inner {
    width: 48px;
    height: 72px;
  }
  .p-card-front,
  .p-card-back {
    border-radius: 6px;
  }
  .p-ranking-strip {
    bottom: -6px;
    gap: 1px;
    padding: 1px;
  }
  .p-ranking-chip {
    width: 3px;
    height: 6px;
  }
  .p-ranking-chip[class*='size-'] {
    width: 10px;
    min-width: 10px;
    height: 9px;
    font-size: 7px;
  }
  .p-name {
    max-width: 56px;
    font-size: 0.65rem;
  }
  .participant-card .you-badge {
    font-size: 0.6rem;
  }
  .vote-cards-grid {
    padding: 14px 12px 20px;
    column-gap: 6px;
    row-gap: 16px;
  }
  .vote-card {
    width: 50px;
    height: 76px;
    font-size: 1rem;
    border-radius: 6px;
  }
  .vote-card.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.3);
  }
  .scale-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }
  .scale-buttons.size-scale {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .scale-btn {
    padding: 7px 3px;
    font-size: 0.8rem;
    border-radius: 6px;
  }
  .calculator {
    padding: 12px 12px;
    gap: 10px;
  }
  .calc-inputs {
    padding: 12px;
    gap: 10px 8px;
    border-radius: 10px;
  }
  .calc-row {
    row-gap: 10px;
  }
  .calc-field label {
    font-size: 0.75rem;
  }
  .calc-hint {
    font-size: 0.7rem;
  }
  .calc-output {
    padding: 12px;
    gap: 12px;
  }
  .calc-result-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .calc-result-item {
    padding: 8px 6px;
    border-radius: 6px;
  }
  .result-label {
    font-size: 0.64rem;
  }
  .result-value {
    font-size: 1.1rem;
  }
  .sp-big {
    font-size: 1.6rem;
  }
  .result-range {
    font-size: 0.62rem;
  }
  .factor-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .factor-chip {
    padding: 7px 6px;
    border-radius: 6px;
  }
  .factor-name {
    font-size: 0.6rem;
  }
  .factor-math {
    font-size: 0.82rem;
  }
  .calc-output .btn {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .fibonacci-heading {
    font-size: 0.8rem;
    margin: 0 10px;
  }
  .results-area {
    padding: 14px;
  }
  .results-title {
    font-size: 0.9rem;
    margin-bottom: 10px;
  }
  .results-votes {
    gap: 8px;
    margin-bottom: 12px;
  }
  .result-vote-chip {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .results-stats {
    gap: 16px;
    padding-top: 10px;
  }
  .stat-label {
    font-size: 0.72rem;
  }
  .stat-value {
    font-size: 0.95rem;
  }
  .game-footer {
    padding: 10px 12px;
    gap: 8px;
  }
  .footer-section {
    gap: 10px;
    flex-wrap: wrap;
  }
  .vote-count {
    font-size: 0.8rem;
  }
  .muted-text {
    font-size: 0.78rem;
  }
  #btn-reveal,
  #btn-next-story {
    width: auto;
    min-width: 110px;
  }
  .modal-box {
    padding: 20px;
  }
  .modal-box h3 {
    font-size: 0.95rem;
  }
  .card {
    padding: 20px;
  }
  .admin-dashboard-head {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-dashboard-head .btn {
    width: 100%;
  }
  .create-card h2,
  .join-card h2 {
    font-size: 1.05rem;
  }
  .card-desc {
    font-size: 0.8rem;
    margin-bottom: 16px;
  }
}

/* ---- Small Mobile (480px - 680px) ---- */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }
  .home-main {
    padding: 16px 8px;
    gap: 16px;
  }
  .hero h1 {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
  }
  .hero-sub {
    font-size: 0.85rem;
    max-width: 100%;
  }
  .card {
    padding: 16px;
    border-radius: 8px;
  }
  .game-header {
    padding: 6px 8px;
    gap: 4px;
  }
  .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    gap: 4px;
  }
  .btn-sm {
    padding: 4px 6px;
    font-size: 0.7rem;
  }
  .icon-btn {
    font-size: 0.9rem;
    padding: 3px 5px;
  }
  .session-title {
    max-width: 60px;
    font-size: 0.75rem;
    font-weight: 700;
  }
  .story-label {
    font-size: 0.65rem;
  }
  .story-value {
    max-width: 100px;
    font-size: 0.75rem;
  }
  .participants-grid {
    gap: 8px;
    min-height: 60px;
  }
  .p-card-inner {
    width: 44px;
    height: 66px;
  }
  .p-name {
    max-width: 50px;
    font-size: 0.6rem;
  }
  .vote-cards-grid {
    padding: 10px 8px 16px;
    column-gap: 5px;
    row-gap: 16px;
  }
  .vote-card {
    width: 46px;
    height: 70px;
    font-size: 0.9rem;
  }
  .vote-card.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.3);
  }
  .scale-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .scale-buttons.size-scale {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .scale-btn {
    padding: 6px 2px;
    font-size: 0.75rem;
    border-radius: 4px;
  }
  .calculator {
    padding: 10px 8px;
    gap: 8px;
  }
  .calc-inputs,
  .calc-output {
    padding: 10px;
    gap: 8px 6px;
    border-radius: 8px;
  }
  .calc-row {
    row-gap: 8px;
  }
  .calc-field label {
    font-size: 0.7rem;
  }
  .calc-hint {
    font-size: 0.65rem;
  }
  .calc-result-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .calc-result-item {
    padding: 6px 4px;
  }
  .result-label {
    font-size: 0.6rem;
  }
  .result-value {
    font-size: 1rem;
  }
  .sp-big {
    font-size: 1.4rem;
  }
  .result-range {
    font-size: 0.58rem;
  }
  .factor-breakdown {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }
  .factor-chip {
    padding: 5px 4px;
  }
  .factor-name {
    font-size: 0.55rem;
  }
  .factor-math {
    font-size: 0.75rem;
  }
  .calc-output .btn {
    padding: 6px 8px;
    font-size: 0.72rem;
  }
  .formula-value {
    font-size: 0.9rem;
  }
  .results-area {
    padding: 10px 8px;
  }
  .results-title {
    font-size: 0.85rem;
  }
  .results-votes {
    gap: 6px;
  }
  .result-vote-chip {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
  .results-stats {
    gap: 12px;
  }
  .game-footer {
    padding: 8px 8px;
    gap: 6px;
  }
  .footer-section {
    gap: 8px;
  }
  .vote-count {
    font-size: 0.75rem;
  }
  .muted-text {
    font-size: 0.75rem;
  }
  .home-divider span {
    padding: 4px 10px;
    font-size: 0.8rem;
  }
  .modal-box {
    padding: 16px;
    max-width: calc(100vw - 32px);
  }
  .modal-box h3 {
    font-size: 0.9rem;
  }
}

/* ---- Extra Small Mobile (< 480px) ---- */
@media (max-width: 380px) {
  html {
    font-size: 14px;
  }
  .home-main {
    padding: 12px 6px;
  }
  .hero h1 {
    font-size: 1.1rem;
  }
  .hero-sub {
    font-size: 0.8rem;
  }
  .card {
    padding: 14px;
  }
  .game-header {
    padding: 4px 6px;
  }
  .status-bar {
    padding: 6px 10px;
    font-size: 0.78rem;
  }
  .vote-card {
    width: 42px;
    height: 64px;
    font-size: 0.85rem;
  }
  .participants-grid {
    gap: 6px;
  }
  .p-card-inner {
    width: 40px;
    height: 60px;
  }
  .p-name {
    max-width: 40px;
    font-size: 0.55rem;
  }
  .scale-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }
  .scale-buttons.size-scale {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .scale-btn {
    padding: 5px 1px;
    font-size: 0.7rem;
  }
}

/* ---- Landscape Orientation Adjustments ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .game-header {
    padding: 6px 12px;
    min-height: 44px;
  }
  .participants-section {
    padding: 6px 12px;
  }
  .participants-grid {
    min-height: 56px;
    gap: 8px;
  }
  .p-card-inner {
    width: 44px;
    height: 62px;
  }
  .status-bar {
    padding: 4px 12px;
    font-size: 0.76rem;
  }
  .game-main {
    padding: 0;
  }
  .calculator {
    padding: 10px 12px;
    gap: 10px;
  }
  .vote-cards-grid {
    padding: 10px 12px;
    column-gap: 6px;
    row-gap: 16px;
  }
  .vote-card {
    width: 44px;
    height: 64px;
  }
  .game-footer {
    padding: 6px 12px;
    gap: 6px;
  }
}
