:root {
    --bg-color: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --input-bg: rgba(0, 0, 0, 0.2);
    --danger-color: #ef4444;
    --blob-1: #7c3aed;
    --blob-2: #2563eb;
    --blob-3: #db2777;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed to start for scrolling */
    padding-top: 50px;
    padding-bottom: 50px;
    overflow-y: auto; /* Allow scrolling */
    position: relative;
}

/* Background Animation */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--blob-1);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--blob-2);
    bottom: -50px;
    right: -50px;
    animation-delay: -2s;
}

.blob-3 {
    width: 200px;
    height: 200px;
    background: var(--blob-3);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -4s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(20px, 40px) scale(1.1); }
}

/* Container & Card */
.container {
    width: 100%;
    max-width: 550px;
    padding: 20px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 5px;
}

.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Time Rows */
#time-rows-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.time-row {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

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

/* Operation Toggle (Small) */
.row-op-toggle {
    width: 40px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-op-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.row-op-toggle.minus {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.row-op-toggle.minus:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Inputs */
.input-wrapper {
    position: relative;
    flex: 1;
}

.input-wrapper input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 10px;
    color: var(--text-primary);
    font-size: 1.2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
}

.input-wrapper span {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}

/* Delete Button */
.delete-btn {
    width: 40px; /* Matched height of inputs approx */
    height: 48px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.delete-btn:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent-color), #2563eb);
    color: white;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(37, 99, 235, 0.5);
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px dashed var(--card-border);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

/* Result Display */
.result-display {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
    text-align: center;
}

.result-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-value {
    font-size: 3rem;
    font-weight: 300;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 5px;
}

.result-value small {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-right: 10px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}
/* History Section */
.history-divider {
    height: 1px;
    background: var(--card-border);
    margin: 30px 0 20px 0;
}

.history-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

.history-expression {
    color: var(--text-secondary);
    font-size: 0.9rem;
    word-break: break-word;
}

.history-result {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    align-self: flex-end;
}
/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
    margin-top: 5px;
    display: inline-block;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}
