/* ==================== GLASS PILL (sidebar-embedded) ==================== */
.sidebar-hud-slot {
    padding: 8px 8px 4px;
    border-top: 0.5px solid rgba(0,0,0,0.06);
    margin-top: auto;
}
.sidebar.collapsed .sidebar-hud-slot {
    display: none;
}

.glass-pill {
    position: relative;
    top: auto;
    right: auto;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.04);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 0.5px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    corner-shape: squircle;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.15s ease;
    overflow: hidden;
    max-width: none;
    width: 100%;
}
.glass-pill::before {
    display: none;
}
.glass-pill:hover {
    max-width: none;
    background: rgba(0,0,0,0.06);
    box-shadow: none;
}

/* Status chip */
.glass-pill-status {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 8px;
    transition: background 0.15s ease;
}
.glass-pill-status:hover {
    background: rgba(0,0,0,0.04);
}
.glass-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pillPulse 3s ease-in-out infinite;
}
@keyframes pillPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.glass-pill-dot.green { background: var(--apple-green); box-shadow: 0 0 6px rgba(52,199,89,0.4); }
.glass-pill-dot.yellow { background: var(--apple-orange); box-shadow: 0 0 6px rgba(255,149,0,0.4); }
.glass-pill-dot.red { background: var(--apple-red); box-shadow: 0 0 6px rgba(255,59,48,0.4); }
.glass-pill-dot.gold { background: var(--apple-yellow); box-shadow: 0 0 6px rgba(255,204,0,0.4); }
.glass-pill-status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Separator */
.glass-pill-sep {
    width: 0.5px;
    height: 16px;
    background: rgba(0,0,0,0.10);
    flex-shrink: 0;
}

/* Fund display — always visible in sidebar */
.glass-pill-fund {
    display: flex;
    align-items: baseline;
    gap: 4px;
    opacity: 1;
    max-width: none;
    overflow: hidden;
    white-space: nowrap;
}
.glass-pill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.glass-pill-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Weather — always visible in sidebar */
.glass-pill-weather {
    display: flex;
    align-items: center;
    gap: 3px;
    opacity: 1;
    max-width: none;
    overflow: hidden;
}
.glass-pill-weather-icon {
    font-size: 14px;
    line-height: 1;
}
.glass-pill-weather-temp {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Pill buttons */
.glass-pill-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: background 0.15s ease, color 0.15s ease;
}
.glass-pill-btn:hover {
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
}
.glass-pill-btn:active {
    transform: scale(0.93);
    transition: transform 80ms var(--spring);
}
.glass-pill-btn .material-symbols-outlined {
    font-size: 16px;
}
.glass-pill-btn.active {
    background: var(--apple-blue);
    color: white;
}

/* Avatar */
.glass-pill-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007AFF, #5AC8FA);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.glass-pill-avatar:hover {
    filter: brightness(1.1);
}
.glass-pill-avatar .material-symbols-outlined {
    font-size: 16px;
    color: var(--text-secondary);
}
.glass-pill-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Value change animation */
.glass-pill-value.value-changed {
    animation: pillValueBounce 0.3s var(--spring-bounce);
}
@keyframes pillValueBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Mobile: hide sidebar HUD slot (no sidebar on mobile) */
@media (max-width: 768px) {
    .sidebar-hud-slot {
        display: none;
    }
}




/* ==================== FLOATING CALCULATOR POPOVER ==================== */
.calc-popover {
    position: fixed;
    bottom: 80px;
    left: calc(var(--sidebar-width) + 16px);
    width: 280px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.25s cubic-bezier(0.4,0,0.2,1),
                transform 0.25s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.calc-popover.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Calculator body — stays put */
.calc-popover-inner {
    background: rgba(246, 246, 248, 0.95);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid rgba(0,0,0,0.04);
    border-radius: 16px;
    box-shadow:
        0 0 0 0.5px rgba(0,0,0,0.06),
        0 12px 40px -8px rgba(0,0,0,0.15),
        0 4px 12px rgba(0,0,0,0.06);
    padding: 12px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

/* Display */
.calc-popover .calc-display {
    background: rgba(255,255,255,0.7);
    border: 0.5px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    text-align: right;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
}
.calc-display-expr {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-quaternary);
    font-family: var(--font-display);
    min-height: 14px;
    transition: opacity 0.15s ease;
}
.calc-display-value {
    font-size: 26px;
    font-weight: 600;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: var(--mono-ls-large);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    transition: color 0.25s ease;
}
.calc-display-value.flash {
    animation: calcValuePop 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes calcValuePop {
    0%   { transform: scale(1); color: var(--system-blue); }
    30%  { transform: scale(1.06); }
    100% { transform: scale(1); color: var(--text-primary); }
}

/* Keypad */
.calc-popover .calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}
.calc-popover .calc-key {
    height: 40px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.08s ease;
    background: rgba(255,255,255,0.7);
    color: var(--text-primary);
    font-family: var(--font-display);
}
.calc-popover .calc-key:hover {
    background: rgba(255,255,255,0.95);
}
.calc-popover .calc-key:active,
.calc-popover .calc-key.pressed {
    transform: scale(0.91);
    background: rgba(0,0,0,0.06);
}
.calc-popover .calc-key.func {
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
    font-weight: 600;
}
.calc-popover .calc-key.op {
    background: rgba(0,122,255,0.1);
    color: var(--system-blue);
    font-weight: 700;
    font-size: 18px;
}
.calc-popover .calc-key.op:hover {
    background: rgba(0,122,255,0.18);
}
.calc-popover .calc-key.op:active,
.calc-popover .calc-key.op.pressed {
    background: rgba(0,122,255,0.3);
    transform: scale(0.91);
}
.calc-popover .calc-key.zero {
    grid-column: span 2;
}
.calc-popover .calc-key.equals {
    background: var(--system-blue);
    color: white;
    font-weight: 700;
    font-size: 18px;
}
.calc-popover .calc-key.equals:hover {
    background: var(--accent-hover);
}
.calc-popover .calc-key.equals:active,
.calc-popover .calc-key.equals.pressed {
    transform: scale(0.91);
    filter: brightness(0.85);
}

/* Bottom bar */
.calc-bottom-bar {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 0.5px solid rgba(0,0,0,0.06);
}
.calc-bottom-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.12s ease;
}
.calc-bottom-btn:hover {
    background: rgba(0,0,0,0.04);
    color: var(--text-secondary);
}

/* ==================== RECEIPT TAPE — grows downward from calc ==================== */
.calc-tape-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    margin: -4px 10px 0;
    position: relative;
    z-index: 1;
}
.calc-tape-wrapper.has-tape {
    max-height: 220px;
}

.calc-tape {
    background: rgba(255, 255, 252, 0.94);
    border: 0.5px solid rgba(0,0,0,0.05);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 10px 14px 6px;
    box-shadow:
        0 4px 16px rgba(0,0,0,0.05),
        inset 0 1px 0 rgba(0,0,0,0.02);
    max-height: 180px;
    overflow-y: auto;
    transition: opacity 0.6s ease;
}
.calc-tape.faded {
    opacity: 0.25;
}
.calc-tape::-webkit-scrollbar { width: 3px; }
.calc-tape::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

/* Tear edge */
.calc-tape-tear {
    height: 7px;
    margin: 0 6px;
    opacity: 0;
    transition: opacity 0.3s ease 0.3s;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='7' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 7 5-7' fill='rgba(255,255,252,0.94)' stroke='rgba(0,0,0,0.04)' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 10px 7px;
    background-repeat: repeat-x;
}
.calc-tape-wrapper.has-tape .calc-tape-tear {
    opacity: 1;
}

/* Tape lines */
.calc-tape-line {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-quaternary);
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    text-align: right;
    padding: 1.5px 0;
    line-height: 1.7;
    letter-spacing: 0.01em;
}
.calc-tape-line.new {
    animation: tapeLineIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.calc-tape-line.result {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14px;
    padding: 2px 0 6px;
    margin-bottom: 4px;
    border-bottom: 0.5px dashed rgba(0,0,0,0.1);
}

@keyframes tapeLineIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scaleY(0.3);
        max-height: 0;
    }
    60% {
        opacity: 1;
        transform: translateY(1px) scaleY(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scaleY(1);
        max-height: 40px;
    }
}

/* Clear tape collapse animation */
.calc-tape-wrapper.clearing {
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    opacity: 0;
    max-height: 0 !important;
}

