:root {
    --primary-color: #7b68ee; /* Medium Slate Blue */
    --primary-hover: #6a5acd;
    --background-dark: #0d1117;
    --surface-dark: #161b22;
    --text-light: #c9d1d9;
    --accent-color: #ff7b72;
    --input-bg: #21262d;
    --tag-bg: #30363d;
    --success-color: #2ea043;
    --border-color: #30363d;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: var(--background-dark);
    color: var(--text-light);
    line-height: 1.6;
    padding-bottom: 100px;
    overflow-x: hidden;
}

/* Header */
header {
    background-color: var(--surface-dark);
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background-color: rgba(22, 27, 34, 0.95);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { margin: 0; font-size: 1.4em; color: white; letter-spacing: 0.5px; }
.logo span { color: var(--primary-color); }
.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, #7b68ee, #ff7b72);
    border-radius: 10px; display: flex; align-items: center; justify-content: center; 
    font-weight: 800; color: white; font-size: 1.2em;
    box-shadow: 0 4px 10px rgba(123, 104, 238, 0.3);
}

.header-actions { display:flex; gap:15px; align-items:center; }
.icon-btn {
    background: var(--tag-bg); border: none; color: white;
    width: 42px; height: 42px; border-radius: 12px;
    cursor: pointer; transition: 0.2s; font-size: 1.1em;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--primary-color); transform: translateY(-2px); }

.donate-btn {
    background: linear-gradient(to right, #f0c300, #f1c40f); 
    color: #1e2228; border: none; padding: 10px 18px; border-radius: 8px;
    cursor: pointer; font-weight: bold; display:flex; align-items:center; gap:8px; 
    transition: 0.2s; font-size: 0.95em;
}
.donate-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(240, 195, 0, 0.3); }

/* Main Content */
main { padding: 25px 5%; max-width: 900px; margin: auto; }

.search-container { position: relative; margin-bottom: 25px; }
.search-container input {
    width: 100%; padding: 14px 14px 14px 50px;
    background-color: var(--surface-dark);
    border: 1px solid var(--border-color); border-radius: 12px;
    color: white; font-size: 1.1em; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: border-color 0.2s;
}
.search-container input:focus { border-color: var(--primary-color); }
.search-container i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #8b949e; font-size: 1.1em; }

.tags-container { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:35px; }
.tag { 
    background-color: var(--tag-bg); padding:8px 18px; border-radius:25px; 
    font-size:0.9em; cursor:pointer; transition:0.2s; user-select:none; border: 1px solid transparent;
}
.tag:hover { border-color: var(--primary-color); }
.tag.active { background-color: var(--primary-color); color: white; box-shadow: 0 4px 10px rgba(123, 104, 238, 0.4); }

/* Cards */
.formula-card {
    background-color: var(--surface-dark);
    padding: 25px; border-radius: 16px;
    margin-bottom: 25px; border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative; overflow: hidden;
}
.formula-card:hover { border-color: var(--primary-color); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }

.card-header h3 { margin: 0 0 5px 0; color: #58a6ff; display:flex; align-items:center; gap:10px; font-size: 1.3em; }
.card-desc { font-size:0.85em; color:#8b949e; margin-bottom:15px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }

.math-display {
    background: #0d1117; padding: 15px; border-radius: 10px;
    text-align: center; font-size: 1.25em; margin-bottom: 25px; 
    border: 1px dashed var(--border-color);
}

.inputs-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;
    margin-bottom: 25px;
}
.input-group label { display:block; font-size:0.85em; margin-bottom:8px; color:#8b949e; font-weight: 500; }
.input-group input {
    width:100%; padding:10px 12px; background:var(--input-bg);
    border:1px solid var(--border-color); border-radius:8px; color:white;
    font-size: 1em; transition: 0.2s;
}
.input-group input:focus { border-color: var(--primary-color); background: #262c36; }

.action-row { 
    display:flex; justify-content:space-between; align-items:center; 
    border-top:1px solid var(--border-color); padding-top:20px; gap:15px; flex-wrap:wrap; 
}
.calc-btn {
    background-color:var(--primary-color); color:white; border:none;
    padding:12px 30px; border-radius:8px; cursor:pointer; font-weight:bold;
    font-size: 1em; transition: 0.2s; box-shadow: 0 4px 10px rgba(123, 104, 238, 0.3);
}
.calc-btn:hover { background-color: var(--primary-hover); transform: scale(1.02); }
.result-area { text-align: right; background: rgba(46, 160, 67, 0.1); padding: 5px 15px; border-radius: 8px; border: 1px solid rgba(46, 160, 67, 0.2); }
.result-display { font-size:1.4em; font-weight:800; color:var(--success-color); }
.unit { font-size:0.9em; color:#8b949e; margin-left:5px; }

/* Modals */
#upi-modal { display:none; position:fixed; z-index:3000; left:0; top:0; width:100%; height:100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); }
.modal-content { 
    position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); 
    width:90%; max-width:400px; background-color:var(--surface-dark); 
    border-radius:16px; border:1px solid var(--primary-color); padding:25px; 
    box-shadow:0 20px 50px rgba(0,0,0,0.8); 
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop { from { transform: translate(-50%, -40%) scale(0.9); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.close { position:absolute; right:15px; top:15px; font-size:24px; color:#8b949e; cursor:pointer; }
.close:hover { color:var(--accent-color); }

.upi-display { 
    background:var(--input-bg); padding:15px; border:1px dashed var(--border-color); 
    border-radius:8px; font-size:1.1em; color:var(--success-color); text-align:center; 
    margin:20px 0; word-break:break-all; font-family: monospace;
}
.copy-btn { width:100%; padding:12px; background-color:var(--primary-color); color:white; border:none; border-radius:8px; cursor:pointer; font-weight:bold; }

#copy-toast { 
    visibility:hidden; min-width:280px; background-color:var(--success-color); 
    color:#fff; text-align:center; border-radius:8px; padding:16px; 
    position:fixed; z-index:5000; left:50%; bottom:30px; transform:translateX(-50%); 
    font-size:16px; box-shadow:0 8px 20px rgba(0,0,0,0.4); opacity:0; transition: 0.3s;
}
#copy-toast.show { visibility:visible; opacity:1; bottom: 40px; }

/* AI Widget */
#ai-widget { 
    position:fixed; bottom:90px; right:20px; width:380px; max-width:90vw; height:550px; 
    background-color:var(--surface-dark); border-radius:15px; 
    box-shadow: -5px 10px 30px rgba(0,0,0,0.6); display:none; flex-direction:column; 
    border:1px solid var(--border-color); z-index:2000; overflow:hidden;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
#ai-widget.open { display:flex; }
.chat-header { padding:15px; background:var(--primary-color); color:white; display:flex; justify-content:space-between; align-items:center; font-weight: bold; }
.iframe-container { flex:1; width:100%; height:100%; background:white; }
.iframe-container iframe { width:100%; height:100%; border:none; }

.chat-toggle-btn { 
    position:fixed; bottom:25px; right:25px; width:60px; height:60px; border-radius:50%; 
    background:linear-gradient(135deg, #7b68ee, #a855f7); color:white; 
    display:flex; align-items:center; justify-content:center; font-size:1.6em; 
    cursor:pointer; box-shadow:0 4px 15px rgba(123, 104, 238, 0.5); z-index:1999; 
    transition:transform 0.2s; 
}
.chat-toggle-btn:hover { transform:scale(1.1) rotate(10deg); }
#ai-widget.open ~ .chat-toggle-btn { display:none; }

/* Calculator Widget */
#simple-calc-modal { 
    position:fixed; top:85px; right:20px; width:280px; 
    background-color: var(--surface-dark); border:1px solid var(--border-color); 
    border-radius:16px; box-shadow:0 10px 40px rgba(0,0,0,0.7); padding:15px; 
    z-index:2500; display:none; opacity: 0; transition: opacity 0.2s;
}
#simple-calc-modal.active { display:block; opacity: 1; }
.sc-display { 
    width:100%; background:#0d1117; color:white; font-size:1.8em; text-align:right; 
    padding:15px; border-radius:8px; margin-bottom:12px; border:1px solid var(--border-color); 
    overflow-x:auto; letter-spacing: 1px;
}
.sc-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.sc-btn { 
    padding:15px 0; border:none; border-radius:8px; font-size:1.2em; cursor:pointer; 
    font-weight:bold; background-color: var(--tag-bg); color:white; transition:0.2s; 
}
.sc-btn:hover { background-color: #454d55; transform: scale(1.05); }
.sc-btn.op { background-color:var(--primary-color); }
.sc-btn.clear { background-color:#d73a49; }
.sc-btn.del { background-color:#e67e22; }

/* Intro Screen */
#intro-screen { 
    position:fixed; top:0; left:0; width:100%; height:100%; 
    background-color:#0d1117; display:flex; justify-content:center; align-items:center; 
    flex-direction:column; z-index:9999; transition: opacity 0.6s ease-out; 
}
.intro-name { 
    font-size:3em; margin:0; opacity:0; transform:translateY(20px); 
    background:linear-gradient(90deg, #7b68ee, #ff7b72, #f0c300); 
    -webkit-background-clip:text; -webkit-text-fill-color:transparent; 
    background-size:300% 300%; 
    animation:nameAnim 1s forwards, colorShift 4s infinite linear; 
}
.intro-tagline { color:#8b949e; margin-top:15px; opacity:0; animation: creditAnim 1s forwards 1s; text-align:center; }
.intro-credit { color:#58a6ff; font-size:0.9em; margin-top:5px; opacity:0; animation: creditAnim 1s forwards 1.5s; text-align:center; }

@keyframes nameAnim { to { opacity:1; transform:translateY(0); } }
@keyframes colorShift { 0% { background-position:0% 50%; } 50% { background-position:100% 50%; } 100% { background-position:0% 50%; } }
@keyframes creditAnim { to { opacity:1; } }

@media (max-width: 600px) {
    header { padding: 15px 3%; }
    .donate-btn span { display: none; }
    .search-container input { font-size: 16px; }
            }
