:root {
    --bg-body: #eef2f5;
    --bg-container: #ffffff;
    --text-color: #333;
    --btn-bg: #f4f7f6;
    --btn-hover: #e0e5e9;
    --accent: #4fa6ff;
    --accent-hover: #3b8cd9;
    --display-bg: #f9f9f9;
    --border: #ddd;
}

body.dark-mode {
    --bg-body: #1e1e2e;
    --bg-container: #28293d;
    --text-color: #e0e0e0;
    --btn-bg: #3a3b52;
    --btn-hover: #4e4f6b;
    --accent: #7aa2f7;
    --accent-hover: #5d87d1;
    --display-bg: #16161e;
    --border: #444;
}

body {
    background: var(--bg-body);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    color: var(--text-color);
    transition: background 0.3s;
}

.container {
    background: var(--bg-container);
    width: 380px;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transition: background 0.3s;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h2 { margin: 0; font-size: 22px; }

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-color);
}

/* DISPLAY */
.display-container {
    background: var(--display-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 15px;
    text-align: right;
}

#display {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 32px;
    text-align: right;
    color: var(--text-color);
    outline: none;
}

#sub-display {
    height: 20px;
    font-size: 14px;
    color: #888;
}

/* TABS */
.tabs { display: flex; gap: 8px; margin-bottom: 15px; }
.tab-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: var(--btn-bg);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.tab-btn.active {
    background: var(--accent);
    color: white;
}

.panel { margin-top: 10px; }
.hide { display: none; }

/* GRIDS */
.std-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.sci-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}
.prog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* BUTTONS */
.btn {
    padding: 15px;
    background: var(--btn-bg);
    color: var(--text-color);
    border: 1px solid var(--border);
    font-size: 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn:hover { background: var(--btn-hover); transform: translateY(-2px); }
.btn.action { color: #ff5f5f; }
.btn.op { color: var(--accent); }
.btn.equal {
    background: var(--accent);
    color: white;
    border: none;
}
.btn.equal:hover { background: var(--accent-hover); }

.wide { grid-column: span 2; }
.wide2 { grid-column: span 2; }

/* PROGRAMMER INPUTS */
.prog-inputs label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    margin-top: 8px;
    color: #888;
}
.prog-inputs input {
    width: 94%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: var(--display-bg);
    color: var(--text-color);
    border-radius: 6px;
    font-family: monospace;
}

/* PLOT */
#plot-function {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
}
.plot-btn {
    padding: 0 15px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}
#plot-canvas {
    width: 100%;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
}

/* HISTORY */
.history-box {
    background: var(--bg-container);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 13px;
}
.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 12px;
}
#history-list div {
    padding: 4px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
#history-list div:hover { background: var(--btn-bg); }
#clear-history {
    background: transparent;
    border: none;
    color: #ff5f5f;
    cursor: pointer;
    font-size: 11px;
}

/* Tombol Aktif (untuk toggle 2nd / DEG) */
.btn.active-mode {
    background: var(--accent);
    color: white;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.2);
}

/* Penyesuaian Grid Scientific agar tombol angka muat */
.sci-grid {
    /* Kita ubah agar baris angka ada di bawah */
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* Font size tombol func sedikit dikecilkan agar muat */
.sci-grid .btn {
    font-size: 14px; 
    padding: 12px 5px; /* Padding lebih kecil */
}