:root {
    --bg-color: #0d0a1a;
    --acc-color: #7b2cf7;
    --acc-hover: #5a19c5;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --glass-bg: rgba(25, 20, 45, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --btn-key: rgba(255, 255, 255, 0.05);
    --btn-key-hover: rgba(255, 255, 255, 0.15);
    --btn-op: #ff9f0a;
    --btn-op-hover: #e08b00;
    --btn-util: rgba(255, 255, 255, 0.2);
    --btn-util-hover: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --neon-blue: #00f2ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: radial-gradient(circle at center, #1e1b4b, #0d0a1b);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    animation: fadeIn 0.8s ease-out;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: 2px;
    background: linear-gradient(to bottom right, #ffffff, var(--acc-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.2rem;
}

header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Calculator Card */
.calculator-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Display */
.display {
    text-align: right;
    padding: 20px 0;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 140px;
}

.expression-row {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    min-height: 1.2rem;
    word-break: break-all;
    transition: all 0.3s ease;
}

.result-row {
    font-size: 3.5rem;
    font-weight: 400;
    line-height: 1.1;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.result-row::-webkit-scrollbar {
    display: none;
}

/* Voice Controls */
.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.voice-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--acc-color);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(123, 44, 247, 0.4);
}

.voice-btn:hover {
    transform: scale(1.05);
    background: var(--acc-hover);
}

.voice-btn:active {
    transform: scale(0.95);
}

.voice-btn.listening {
    background: #ff3b30;
    animation: listeningPulse 1.5s infinite ease-out;
}

@keyframes listeningPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(255, 59, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.status.active {
    color: var(--neon-blue);
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 12px;
}

.key {
    background: var(--btn-key);
    border: none;
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 500;
    padding: 16px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.key:hover {
    background: var(--btn-key-hover);
}

.key:active {
    transform: scale(0.92);
}

.key.op {
    background: var(--btn-op);
    font-size: 1.5rem;
}

.key.op:hover {
    background: var(--btn-op-hover);
}

.key.util {
    background: var(--btn-util);
    font-size: 1rem;
    font-weight: 600;
}

.key.util:hover {
    background: var(--btn-util-hover);
}

.key.zero {
    grid-column: span 2;
    padding-left: 24px;
    justify-content: flex-start;
}

.key.equal {
    background: #ffffff;
    color: #000;
}

.key.equal:hover {
    background: #f0f0f0;
}

/* Scroll handling for display */
.expression-row, .result-row {
    user-select: none;
}
